import Vue from 'vue'
import VueRouter from 'vue-router'
import home from '../views/home'
/*import Welcome from ''
import users from ''
import rights from ''
import roles from ''
import cate from ''
import list from ''
import add from ''
import order from ''
import report from ''
import params from ''
import categories from ''*/

Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    component: home
  },
  {
    path: '/product/detail',
    component: () =>import('../views/client/ProductDetail.vue')
  },
  {
    path: '/settlement',
    component: () =>import('../views/client/Settlement.vue')
  },
  {
    path: '/personal',
    component: () =>import('../views/client/personal/Personal.vue')
  },
  {
    path: '/activity',
    component: () =>import('../views/client/activity/Activity')
  },
  {
    path: '/user/login',
    component: () =>import('../views/client/login/login2')
  },
  {
    path: '/user',
    component: () =>import('../views/client/HomePage')
  },
  {
    path: '/cart',
    component: () =>import('../views/client/cart/Cart.vue')
  },
  {
    path: '/',
    component: () =>import('../views/admin/login/Login')
  },
  {
    path: '/admin/login',
    component: () =>import('../views/admin/login/Login.vue')
  },
  {
    path: '/list',
    component: () =>import('../views/client/list/List.vue')
  },
  { path: '/admin',
    component:  () =>import('../views/admin/layout/Home.vue'),
    redirect:'/welcome',
    children: [
      { path: '/cate', component: () =>import('../views/admin/goods/Cate.vue'), meta: {title: '商品分类'} },
      { path: '/params', component: () =>import('../views/admin/goods/Params.vue'),meta: {title: '商品参数'} },
      { path: '/goods', component: () =>import('../views/admin/goods/List.vue'), meta: {title: '商品列表'} },
      { path: '/goods/add', component: () =>import('../views/admin/goods/Add.vue') },
      { path: '/orders', component: () =>import('../views/admin/order/Order.vue') },
      { path: '/users', component: () =>import('../views/admin/user/User.vue') },
      { path: '/roles', component: () =>import('../views/admin/power/Roles.vue') },
      { path: '/rights', component: () =>import('../views/admin/power/Rights.vue') },
      { path: '/reports', component: () =>import('../views/admin/report/Report.vue') },
      { path: '/categories', component: () =>import('../views/admin/goods/Cate.vue') },
      { path: '/banner/lists', component: () =>import('../views/admin/banner/List.vue') },
      { path: '/banner/add', component: () =>import('../views/admin/banner/Add.vue') },
      { path: '/activity/Appointments', component: () =>import('../views/admin/activity/Appointments.vue') },
      { path: '/activity/trade', component: () =>import('../views/admin/activity/Trade.vue') },
      { path: '/welcome', component: () =>import('../views/admin/Welcome.vue') }
    ] }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

/*router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})*/

export default router
